<template>
  <BaseChartVue :width="width" :height="height" :options="chartData"></BaseChartVue>

</template>

<script>
  import BaseChartVue from '../BaseChart.vue'
  import {houseSearch} from "@/api/user";

  export default {
    components: {
      BaseChartVue
    },
    data(){
      return{
        condition:{
          houseid:'',
          code:'',
          status:0,
          address:'',
          page:1,
          limit:10000,
        },
        condition1:{
          houseid:'',
          code:'',
          status:1,
          address:'',
          page:1,
          limit:10000,
        },
        width: '100%',
        height: '100%',

        chartData:{
          title: {
            text: '房屋状态',
            left: '20%',
            top:'center',
            textStyle: {
              color: '#000',
              fontSize: '10',
            }
          },
          tooltip: {
            trigger: 'item'
          },
          grid: {
            left: '0%',
            right: '2%',
            bottom: '0%',
            containLabel: true
          },
          legend: {
            orient: 'vertical',
            left: 'right',
            top:'center'
          },
          series: [
            {
              left: '-100',
              name: '房屋',
              type: 'pie',
              radius: ['60%','80%'],
              data:[
                { value: null, name: '空置中' },
                { value: null, name: '使用中' },
              ],
              emphasis: {
                itemStyle: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
              },
              labelLine: {
                show: false
              },
              label:{
                show:false
              }
            }
          ]

        }
      }

    },
    mounted(){
      this.search()
    },
    methods:{
      search(){
        houseSearch(
                this.condition
        ).then((res)=>{
          this.chartData.series[0].data[0].value = res.count ;
        })
        houseSearch(
                this.condition1
        ).then((res)=>{
          this.chartData.series[0].data[1].value= res.count ;
        })
      },
    }

  }
</script>

<style>

</style>